local BankLayer = class("BankLayer", require "widget/BaseUI")
 
function BankLayer.show()
    print("============BankLayer.show===============")
 
    local win = BankLayer.new()

    local data = getWndInitParamList()
    data.isRemoveResource = false
    data.imgTitle = nil
    data.bgImage = nil
    data.isShowCover = false,

    win:init(data)
    win:showWindow()

    return win

end

function BankLayer:ctor() 
    BankLayer.super:ctor();
end


function BankLayer:init(data)
    self:initWithParas(data)
    
    self.m_Json = ccs.GUIReader:getInstance():widgetFromJsonFile("image/ui/Json/LayerBank.json")
    self:setContentSize(self.m_Json:getContentSize())
    self.m_Json:setPositionX(-self.m_Json:getContentSize().width/2)
    self.m_Json:setPositionY(-self.m_Json:getContentSize().height/2)
    self:addChild(self.m_Json)
    
    self.m_TextFieldGiveGold = self.m_Json:getChildByName("tf_PresenGold")
    self.m_TextFieldAccounts = self.m_Json:getChildByName("tf_PresentID")
    self.m_TextFieldPassWord = self.m_Json:getChildByName("tf_PassWord")
    self.m_TextFieldSaveGold = self.m_Json:getChildByName("tf_SaveGold")
    
    self.m_LabelSaveUserGold = self.m_Json:getChildByName("SaveUser_Gold")
    self.m_LabelSaveBankGold = self.m_Json:getChildByName("SaveBank_Gold")
    self.m_LabelPresentUserGold = self.m_Json:getChildByName("PresentUser_Gold")
    self.m_LabelPresentBankGold = self.m_Json:getChildByName("PresentBank_Gold")
 
    self.m_BtnGive1 = ccui.Helper:seekWidgetByName(self.m_Json,"item0")
    self.m_BtnGive1:setTouchEnabled(true)
    self.m_BtnGive1:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnGive2 = ccui.Helper:seekWidgetByName(self.m_Json,"item1")
    self.m_BtnGive2:setTouchEnabled(true)
    self.m_BtnGive2:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnSure = ccui.Helper:seekWidgetByName(self.m_Json,"bt_Sure")
    self.m_BtnSure:setTouchEnabled(true)
    self.m_BtnSure:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    
    self.m_BtnSaveGold = ccui.Helper:seekWidgetByName(self.m_Json,"bt_SaveGold")
    self.m_BtnSaveGold:setTouchEnabled(true)
    self.m_BtnSaveGold:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnGetGold = ccui.Helper:seekWidgetByName(self.m_Json,"bt_GetGold")
    self.m_BtnGetGold:setTouchEnabled(true)
    self.m_BtnGetGold:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)

    self.m_BtnPresents = ccui.Helper:seekWidgetByName(self.m_Json,"bt_Presents")
    self.m_BtnPresents:setTouchEnabled(true)
    self.m_BtnPresents:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
    
    self.m_BtnBack = self.m_Json:getChildByName("bt_back")
    self.m_BtnBack:setTouchEnabled(true)
    self.m_BtnBack:addTouchEventListener(function(sender,eventType)self:onMenutClick(sender,eventType) end)
 
  
end


function BankLayer:onMenutClick(sender,eventType)
    if eventType == ccui.TouchEventType.ended then
       if sender == self.m_BtnGive1 then     
            print "=========BankLayer:onMenutClick m_BtnGive1======================="
        elseif sender == self.m_BtnGive2 then     
            print "=========BankLayer:onMenutClick m_BtnGive2======================="
        elseif sender == self.m_BtnSure then     
            print "=========BankLayer:onMenutClick m_BtnSure======================="
        elseif sender == self.m_BtnSaveGold then     
            print "=========BankLayer:onMenutClick m_BtnSaveGold======================="
        elseif sender == self.m_BtnGetGold then     
            print "=========BankLayer:onMenutClick m_BtnGetGold======================="
        elseif sender == self.m_BtnPresents then     
            print "=========BankLayer:onMenutClick m_BtnPresents======================="
        elseif sender == self.m_BtnBack then     
            print "=========BankLayer:onMenutClick m_BtnBack======================="
            self:closeWindow()
        end
    end
end
 
return BankLayer